package com.gwz.sys.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.gwz.sys.domain.Dept;
import com.gwz.sys.mapper.DeptMapper;
import com.gwz.sys.service.DeptService;
import com.gwz.sys.utils.DataGridView;
import com.gwz.sys.vo.DeptVo;

@Service
@Transactional
public class DeptServiceImpl implements DeptService {

	@Autowired
	private DeptMapper deptMapper;
	
	@Override
	public List<Dept> queryAllDeptForList(DeptVo deptVo) {
		return deptMapper.queryAllDept(deptVo);
	}

	@Override
	public DataGridView queryAllDept(DeptVo deptVo) {
		Page<Object> page = PageHelper.startPage(deptVo.getPage(), deptVo.getLimit());
		List<Dept> data = deptMapper.queryAllDept(deptVo);
		return new DataGridView(page.getTotal(), data);
	}

	@Override
	public Integer queryMaxOrderNumber() {
		return deptMapper.queryMaxOrderNumber();
	}

	@Override
	public void addDept(DeptVo deptVo) {
		deptMapper.insertSelective(deptVo);
	}

	@Override
	public void updateDept(DeptVo deptVo) {
		deptMapper.updateByPrimaryKeySelective(deptVo);
	}

	@Override
	public Integer CurrentIsChidren(Integer id) {
		return deptMapper.CurrentIsChidren(id);
	}

	@Override
	public void deleteDept(Integer id) {
		deptMapper.deleteByPrimaryKey(id);
	}

}
